package com.game.pool {
	import com.game.units.Enemy;

	public class EnemyPool {
		private var unusedList:Vector.<Enemy> = new Vector.<Enemy>(20);
		public function EnemyPool() {
			for (var i:int = 0; i < 20; i++) {
				unusedList[i] = new Enemy();
			}
		}
		public function getObject():Enemy {
			if (unusedList.length <= 0) {
				return null;
			}
			return unusedList.pop();
		}
		public function returnObject(obj:Enemy):void {
			if (obj == null || unusedList.length == 20) {
				return;
			}
			unusedList.push(obj);
		}
	}
}